﻿package tests;
import mclight.buttons.CheckBox;
import mclight.selectors.ColorChooser;
import mclight.text.InputText;
import mclight.text.Label;
import mclight.containers.Panel;
import mclight.indicators.ProgressBar;
import mclight.buttons.PushButton;
import mclight.buttons.RadioButton;
import mclight.selectors.HSlider;
import mclight.selectors.VSlider;
import flash.display.Sprite;
import flash.events.Event;

class CommonTest extends GenericTest
{
	public function new() 
	{
		super();
	}
	
	var _progressBar:ProgressBar;
	
	override function init()
	{
		var panel:Panel = new Panel(this, stage.stageWidth / 4, stage.stageHeight / 8);
		panel.setSize(stage.stageWidth / 2, stage.stageHeight * 3 / 4);
		
		var checkBox:CheckBox = new CheckBox(panel, 20, 20);
		checkBox.label = "Check it out!";
		
		var label:Label = new Label(panel, 20, 40);
		label.text = "This is a label";
		
		var pushbutton:PushButton = new PushButton(panel, 20, 60, onClick);
        pushbutton.label = "Push Me!";
        pushbutton.width = 100;
		
		var hSlider:HSlider = new HSlider(panel, 20, 90);
		
		var vSlider:VSlider = new VSlider(panel, 130, 20);
		
		var inputText:InputText = new InputText(panel, 20, 110);
		inputText.text = "Input Text";
		_progressBar = new ProgressBar(panel, 20, 140);
		
		var radio1:RadioButton = new RadioButton(20, 160, "Choice 1", true);
		panel.add(radio1);
		
		var radio2:RadioButton = new RadioButton(panel, 20, 180);
        radio2.label = "Choice 2";
		
		var radio3:RadioButton = new RadioButton(panel, 20, 200);
        radio3.label = "Choice 3";
		
		var colorchooser:ColorChooser = new ColorChooser(panel, 20, 230);
        colorchooser.value = 0xff0000;
		
		addEventListener(Event.ENTER_FRAME, onEnterFrame);
		
		radio1.remove();
		panel.add(radio1);
		
		new RadioButton(this, 10, 10, 'Choice4');
		new RadioButton(this, 10, 40, 'Choice5');
	}
	
	function onEnterFrame(e:Event)
	{
		_progressBar.value += 1;
		if (_progressBar.value >= _progressBar.maxValue)
		{
			_progressBar.value = 0;
		}
	}
	
	function onClick(Void):Void
	{
		trace('click');
	}
}